// 抽奖结果提示
const componentBehavior = require('../../../behaviors/component');
const { COMPONENT_OPTIONS } = require('../../../constants/common');

Component({
    behaviors: [componentBehavior],
    options: {
        ...COMPONENT_OPTIONS,
    },
    properties: {
        show: {
            type: Boolean,
            value: false,
        },
        // 是否中奖
        isWinning: {
            type: Boolean,
            value: false,
        },
        award: {
            type: Object,
            value: {},
        },
    },
    observers: {
        'show': function (val) {
            if (val) {
                setTimeout(() => {
                    this.animate('#lottery-tip', [
                        { scale: [0.1, 0.1] },
                        { scale: [0.6, 0.6] },
                        { scale: [1.1, 1.1] },
                        { scale: [1, 1] },
                        ], 800, () => {
                            this.clearAnimation('#lottery-tip', { scale: [1, 1] }, () => {});
                        });
                }, 100)
            }
        },
    },

    data: {

    },
    methods: {
        handleClose() {
            const { isWinning } = this.data;
            this.setData({
                show: false,
            }, () => {
                this.triggerEvent('close', isWinning);
            });
        },
    }
})
